home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / util / wb / sysi2.lha / bitmap.c next >
C/C++ Source or Header  |  1997-02-11  |  991b  |  57 lines

  1. #include "sysi2.h"
  2.  
  3. struct BitMap *MyAllocBM(LONG Width, LONG Height, LONG Depth, LONG Flags, struct BitMap *Friend)
  4. {
  5.   if(IntuitionBase->LibNode.lib_Version>=39)
  6.   {
  7.     return(AllocBitMap(Width,Height,Depth,Flags,Friend));
  8.   }
  9.   else
  10.   {
  11.     struct BitMap *bm;
  12.     LONG l,fail=0;
  13.     
  14.     
  15.     if(bm=AllocVec(sizeof(struct BitMap),MEMF_PUBLIC|MEMF_CLEAR))
  16.     {
  17.       InitBitMap(bm,Depth,Width,Height);
  18.       Width=bm->BytesPerRow * 8;
  19.       for(l=0;l<Depth;l++)
  20.       {
  21.         if((bm->Planes[l]=AllocRaster(Width,Height))==0)
  22.           fail=1;
  23.       }
  24.       
  25.       if(fail)
  26.       {
  27.         MyFreeBM(bm);
  28.         return(0);
  29.       }
  30.       return(bm);
  31.     }
  32.   }
  33. }
  34.  
  35. void MyFreeBM(struct BitMap *BM)
  36. {
  37.   LONG l;
  38.   
  39.   if(BM)
  40.   {
  41.     if(IntuitionBase->LibNode.lib_Version>=39)
  42.     {
  43.       FreeBitMap(BM);
  44.     }
  45.     else
  46.     {
  47.       for(l=0;l<BM->Depth;l++)
  48.       {
  49.         if(BM->Planes[l])
  50.           FreeRaster(BM->Planes[l],BM->BytesPerRow,BM->Rows);
  51.       }
  52.       FreeVec(BM);
  53.     }
  54.   }
  55. }
  56.  
  57.